<?php
/**
 * PHPMailer
 * 
 * @category	Loader
 * @package		dayscript.loader.adapter
 * @subpackage	
 * @author		Harold Roa <hroa@dayscript.com>
 * @copyright	2010 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @version		$Revision: 0 $
 * @filesource	
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		
 * @since		1.0
 * @modifiedby	$LastChangedBy: Harold Roa $
 * @modified	$Date: 2010-01-21 $
 */

namespace dayscript\loader\adapter;

/**
 * PHPMailer
 * 
 * Library auto loader for PHPMailer framework.
 * 
 * @category	Loader
 * @package		dayscript.loader.adapter
 * @subpackage	
 * @author		Harold Roa <hroa@dayscript.com>
 * @copyright	2010 Dayscript Ltda.
 * @license		
 * @version		1.0
 * @link		http://www.dayscript.com
 * @link		{docsLink}
 * @uses		\dayscript\loader\Loader
 * @since		1.0
 * @modifiedby	$LastChangedBy: Harold Roa $
 * @modified	$Date: 2010-01-21 $
 */
class PHPMailer extends \dayscript\loader\Loader	{
	
	private $phpMailerClasses = array("POP3", "SMTP", "PHPMailer");
	/**
	 * PHPMailer constructor
	 * @param string $name Loader identifier
	 * @param string $libraryDir Directory where the PHPMailerLoader framework is placed with a trailing DIRECTORY_SEPARATOR.
	 * @return PHPMailer
	 */
	
	public function __construct( $name, $libraryDir )	{
		parent::__construct( $name, $libraryDir, '.php' );
	}
	/**
	 * {@inheritdoc }
	 */
	public function canLoadClass( $className )	{
		return ( \in_array($className, $this->phpMailerClasses )  && \file_exists( $this->libraryDir . \DIRECTORY_SEPARATOR . 'class.' . \strtolower( $className ) . $this->extension ) );
	}
	/**
	 * {@inheritdoc }
	 */
	public function loadClass( $className )	{
		if( \in_array($className, $this->phpMailerClasses ) )
			require( $this->libraryDir . \DIRECTORY_SEPARATOR . 'class.' . \strtolower( $className ) . $this->extension );
			
	}
}
